package com.hl.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.hl.order.domain.SystemConf;
import com.hl.order.service.ISystemConfService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 系统配置Controller
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@RestController
@RequestMapping("/conf")
public class SystemConfController extends BaseController
{
    @Autowired
    private ISystemConfService systemConfService;

    /**
     * 查询系统配置列表
     */
    @RequiresPermissions("order:conf:list")
    @GetMapping("/list")
    public TableDataInfo list(SystemConf systemConf)
    {
        startPage();
        List<SystemConf> list = systemConfService.selectSystemConfList(systemConf);
        return getDataTable(list);
    }

    /**
     * 导出系统配置列表
     */
    @RequiresPermissions("order:conf:export")
    @Log(title = "系统配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SystemConf systemConf)
    {
        List<SystemConf> list = systemConfService.selectSystemConfList(systemConf);
        ExcelUtil<SystemConf> util = new ExcelUtil<SystemConf>(SystemConf.class);
        util.exportExcel(response, list, "系统配置数据");
    }

    /**
     * 获取系统配置详细信息
     */
    @RequiresPermissions("order:conf:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(systemConfService.selectSystemConfById(id));
    }

    /**
     * 新增系统配置
     */
    @RequiresPermissions("order:conf:add")
    @Log(title = "系统配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SystemConf systemConf)
    {
        return toAjax(systemConfService.insertSystemConf(systemConf));
    }

    /**
     * 修改系统配置
     */
    @RequiresPermissions("order:conf:edit")
    @Log(title = "系统配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SystemConf systemConf)
    {
        return toAjax(systemConfService.updateSystemConf(systemConf));
    }

    /**
     * 删除系统配置
     */
    @RequiresPermissions("order:conf:remove")
    @Log(title = "系统配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(systemConfService.deleteSystemConfByIds(ids));
    }
}
